package org.yate.oa.service.imp;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.yate.oa.dao.IBaseMapperDao;
import org.yate.oa.dao.mapper.HistoryMapper;
import org.yate.oa.model.HistoryEntity;
import org.yate.oa.service.IHistoryService;
import org.yate.oa.utils.Pagination;

@Service
public class HistoryService extends BaseService<HistoryEntity, Integer> implements IHistoryService {

	@Resource(name = "historyMapper")
	private HistoryMapper historyDao;

	@Override
	public void add(HistoryEntity e) {
		historyDao.add(e);
	}

	@Override
	public void update(HistoryEntity e) {
		historyDao.update(e);
	}

	@Override
	public List<HistoryEntity> getEntitiesBy(HistoryEntity e) {
		return historyDao.getEntitiesBy(e);
	}

	@Override
	protected IBaseMapperDao<HistoryEntity, Integer> getMapperDao() {
		return this.historyDao;
	}

	@Override
	public List<HistoryEntity> getEntities() {
		return historyDao.getEntities();
	}

	@Override
	public Pagination<HistoryEntity> getEntitiesByCreaterId(int page, int rows, String orderField, String orderMode, String... strs) {
		Pagination<HistoryEntity> result = new Pagination<HistoryEntity>(page, rows);
		result.setRows(this.historyDao.getEntitiesByCreaterId(result, orderField, orderMode, strs));
		return result;
	}

	@Override
	public Pagination<HistoryEntity> getEntitiesByCreaterId2(int page, int rows, String orderField, String orderMode, String... strs) {
		Pagination<HistoryEntity> result = new Pagination<HistoryEntity>(page, rows);
		result.setRows(this.historyDao.getEntitiesByCreaterId2(result, orderField, orderMode, strs));
		return result;
	}

	@Override
	public Pagination<HistoryEntity> getEntitiesByApproverId(int page, int rows, String orderField, String orderMode, String... strs) {
		Pagination<HistoryEntity> result = new Pagination<HistoryEntity>(page, rows);
		result.setRows(this.historyDao.getEntitiesByApproverId(result, orderField, orderMode, strs));
		return result;
	}

	public Pagination<HistoryEntity> getEntitieSearch(int page, int rows, String orderField, String orderMode, Map<String, Object> map) {
		Pagination<HistoryEntity> result = new Pagination<HistoryEntity>(page, rows);
		result.setRows(this.historyDao.getEntitieSearch(result, orderField, orderMode, map));
		return result;
	}

	public List<HistoryEntity> getEntitiesBySearch(Map<String, Object> map) {
		return historyDao.getEntitieSearch(map);
	}
}
